<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>兑换管理</title>
    <script type="text/javascript" src="/js/jquery.js"></script>
</head>
<body>

<ul id="J_list">


</ul>

<script>
    var page = 1;
    var rows = 10;
    $(function(){
        getExchangeList();
    });


function getExchangeList(){
    var uid = "${uid}";
    var data = {page:page,rows:rows,uid:uid};
    var url = "/exchange/list";
    $.ajax({
        type: "POST",
        dataType: 'json',
        async: false,
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(data),
        url: url,
        success: function(res){
            if(res.code = "200"){
                //操作
                var list = res.data.list;
                console.log(list);
                for (var i =0; i<list.length;i++){
                    var shtml = "";
                    shtml += '<li><div>兑换单号:'+list[i]['order_no']+'</div> ';
                    //type 订单类型:0:自提/1:发货
                    //status 是否核销 0:已申请/1:待核销(待发货)/2:已核销 （待发货）
                    if(list[i]['type'] == 1 && list[i]['status'] == 1){
                        shtml += "<div>待核销</div>";
                    }else if(list[i]['type'] == 1 && list[i]['status'] == 2){
                        shtml += "<div>已核销</div>";
                    }else if(list[i]['type'] == 2 && list[i]['status'] == 1){
                        shtml +=  "<div>已发货</div>";
                    }else if(list[i]['type'] == 2 && list[i]['status'] == 2){
                        shtml +=  "<div>已收货</div>";
                    }
                    shtml += ' <div id="'+list[i]['id']+'"><img src="'+list[i]['pic']+'" width="100px" height="100px" border="1px solid #000" alt=""><div>'+list[i]['title']+'</div></div>';
                   if(list[i]['type'] == 0){
                        shtml += '上门自提';
                    }else{
                        shtml += '<div>'+list[i]['name']+'-'+list[i]['phone']+'</div><div>'+list[i]['address']+'</div>';
                    }
                    shtml +='</li>';
                    $("#J_list").append(shtml);
                }
            }else{
                alert(res.msg);
            }
        },
        error: function(e){

        },
        complete: function(e){

        }
    });

}
</script>

</body>
</html>
